package com.sumainfor.pc.market.controller;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.service.CommunityZfeignService;
import com.sumainfor.pc.market.service.RdTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @Date 2018年11月7日
 * @Describe 工程部查询房源配置
 */
@RestController
@RequestMapping("/key/CommunityZfeign")
public class CommunityZfeignController implements Serializable {
    @Autowired
    private CommunityZfeignService communityZfeignService;
    @Autowired
    private RdTenantService rdTenantService;
    /**
     * 查询所有的房源名称（用于下拉框筛选）
     *
     * @param
     * @return
     */
    @GetMapping("/getCommunityName")
    public JsonResult getCommunityName(Map<String,Object> params) {
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=communityZfeignService.getCommunityName(params);
        if (list==null){
            result.error("服务器繁忙");
        }else{
            result.put(list);
        }
        return result;
    }

    /**
     * 根据房源编号 分页 模糊 条件查询房源信息
     *
     * @return
     */
    @PostMapping("/getCommunityList")
    public JsonResult getCommunityList(@RequestBody Map<String, Object> params) {
        JsonResult result=new JsonResult();
        List<Map<String,Object>> tList=(List<Map<String,Object>>)params.get("TenantList");
        if(tList.size()>0){//1.普通用户，2.管家
            tList= rdTenantService.getTenantListByTenId(params);
        }
        List<Map<String,Object>> list=communityZfeignService.getCommunityList(params);
        if(list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        result.put("tenList",tList);
        return result;
    }
    /**
     * 维修师傅根据获取项目编号列表
     */
    @PostMapping("/getComIdList")
    public JsonResult getComIdList(@RequestBody Map<String, Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=communityZfeignService.getComIdList(params);
        if (list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }


   /**
    *  根据省市区街道楼号室号获取房源集合
    * @author zhoucong
    * @data 2019/9/10
    * @Param
    * @return
    */
    @PostMapping("/getHouInfoList")
    public JsonResult getHouInfoList(@RequestBody Map<String,Object> params){
        JsonResult result = new JsonResult();
        List<Map<String,Object>> list = communityZfeignService.getHouInfoList(params);
        if (list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }


    /**
     * 服务管家验房列表查询
     */
    @PostMapping("/getHouIdList")
    public JsonResult getHouIdList(@RequestBody Map<String, Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=communityZfeignService.getHouIdList(params);
        if (list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 通过房源编号获取对应房源房源信息
     */
    @PostMapping("/getHouIdInfoList")
    public JsonResult getHouIdInfoList(@RequestBody Map<String, Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=communityZfeignService.getHouIdInfoList(params);
        if (list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
}
